package org.example.config;

import org.example.controller.interceptor.ProjectInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
@Configuration
public class springMvcSupport extends WebMvcConfigurationSupport {
    @Autowired
    private ProjectInterceptor ProjectInterceptor;
    @Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 修复：添加资源位置
        registry.addResourceHandler("/pages/**")
                .addResourceLocations("/pages/"); // 指定实际资源位置
    }

    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new ProjectInterceptor())
                .addPathPatterns("/food/**")  // 拦截/food路径下的所有请求
                .addPathPatterns("/**");       // 或者拦截所有请求
    }

}
